﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FrameWork.Output
{
    /// <summary>
    /// 为输出项类型提供枚举
    /// </summary>
    public enum OutputType
    {
        Info,
        Waring,
        Error
    }

    /// <summary>
    /// 表示一个基础的输出项
    /// </summary>
    public class OutputItem
    {
        /// <summary>
        /// 获取该输出项的类型
        /// </summary>
        [DisplayName("输出类型")]
        [Description("表示该输出项的类型")]
        public OutputType OutputType { get; private set; }
        /// <summary>
        /// 获取该输出项的输出文本
        /// </summary>
        [DisplayName("信息")]
        [Description("表示该输出项的简要信息")]
        public string OutputString { get; private set; }
        /// <summary>
        /// 获取该输出项的详细信息
        /// </summary>
        [DisplayName("详细信息")]
        [Description("表示该输出项的详细信息")]
        public string DetailString { get; private set; }
        /// <summary>
        /// 获取该输出项的自定义数据
        /// </summary>
        [DisplayName("关联的数据")]
        [Description("表示该输出项关联的数据")]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public object Tag { get; private set; }
        /// <summary>
        /// 通过指定选项创建输出项的实例
        /// </summary>
        /// <param name="OutputType">该输出项的类型</param>
        /// <param name="OutputString">该输出项内容的简单文本表示</param>
        /// <param name="Tag">该输出项的用户自定义数据</param>
        /// <param name="DetailString">该输出项内容的详细文本表示</param>
        public OutputItem(OutputType OutputType,string OutputString,object Tag=null,string DetailString="")
        {
            this.OutputType = OutputType;
            this.OutputString = OutputString;
            this.Tag = Tag;
            this.DetailString = DetailString;
        }
    }

    /// <summary>
    /// 为输出采集器提供接口
    /// </summary>
    public abstract class  OutputCollectorBase
    {

        #region==========属性==========

        /// <summary>
        /// 获取该采集器是否已经启动
        /// </summary>
        public bool IsStarted { get; protected set; }

        #endregion

        #region========公有委托========

        public delegate void NewOutputGetEventHandler(object sender, OutputEventArgs e);

        #endregion

        #region==========事件==========

        public abstract event NewOutputGetEventHandler NewOutputGet;

        #endregion

        #region========抽象函数========

        /// <summary>
        /// 开启当前数据采集器
        /// </summary>
        public abstract void Start();
        /// <summary>
        /// 停止当前数据采集器
        /// </summary>
        public abstract void Stop();
        /// <summary>
        /// 获取唯一表示该采集器的字符串
        /// </summary>
        /// <returns></returns>
        public abstract string GetCollectorType();

        #endregion
    }

}
